<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8" >
		 
		<title></title>
		<link rel="stylesheet" href="../layui/css/layui.css" media="all" />
	</head>
	<body>
		<div class="layui-row" id="test">
			<div class="layui-col-md9 lay layui-col-md-offset1">
				<form class="layui-form" action="" id="formList">
					<div class="layui-form-item">
						<label class="layui-form-label">姓名(必填)</label>
						<div class="layui-input-block">
							<input type="text" name="name" required lay-verify="required" placeholder="请输入姓名" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">学校(必填)</label>
						<div class="layui-input-block">
							<input id="school" type="text" name="school" required lay-verify="required" placeholder="请输入学校" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">手机电话(必填)</label>
						<div class="layui-input-block">
							<input id="phone" type="text" name="phone" required lay-verify="required" placeholder="请输入手机电话" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">编号(必填)</label>
						<div class="layui-input-block">
							<input id="number" type="text" name="number" required lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">填表时间</label>
						<div class="layui-input-block">
							<input type="date" name="createTime" placeholder="请输入填表时间" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-block">
							<input type="text" name="sex" placeholder="请输入性别" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">学历</label>
						<div class="layui-input-block">
							<input type="text" name="education" placeholder="请输入学历" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">职称</label>
						<div class="layui-input-block">
							<input type="text" name="position" placeholder="请输入职称" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">职务</label>
						<div class="layui-input-block">
							<input type="text" name="post" placeholder="请输入职务" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item" hidden="hidden">
						<label class="layui-form-label">id</label>
						<div class="layui-input-block">
							<input type="text" name="id" placeholder="请输入是/否" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
			<script src="../js/jquery-1.12.4/jquery.min.js"></script>
			<script src="../bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
			<script src="../js/jquery-2.1.4/jquery.min.js"></script>
			<script type="text/javascript" src="../layui/layui.js"></script>
			<script type="text/javascript" src="../js/ip.js"></script>
			<script type="text/javascript">
				var index = parent.layer.getFrameIndex(window.name);
				var test = document.getElementById('school');
				layui.use('form', function() {
					var form = layui.form;
					//监听提交
					form.on('submit(formDemo)', function(data) {
						postDatatoServer(data.field);
						return false;
					});
				});

				function postDatatoServer(data){
					let postaddress;
					if(data.id) {
						postaddress = ip + '/rater/edit';
						data.scoreInfoId = 1;
					}else{
						postaddress = ip + '/rater/add';
						data.scoreInfoId = 1;
						data.id = 1;
					}
					$.ajax({
						type: "POST",
						dataType: "json",
						contentType: "application/json;charset=utf-8",
						url: postaddress,
						data: JSON.stringify(data),
						success: function(result) {
							if ( result.code == 0 ) {  
					            parent.$("#handle_status").val('1');  
					              parent.layer.close(index);  
					        } else {  
					            parent.$("#handle_status").val('2');  
					            parent.layer.close(index);  
					        }
						},
						error: function() {
							alert("错误");
						}
					});
				}
			</script>
	</body>

</html>